package main

import "fmt"

type subscriber struct {
	name   string
	rate   float64
	active bool
}

func applyDiscount(s *subscriber) {
	s.rate = 4.99
}

type myStuct struct {
	myField int
}

func main() {
	var s subscriber
	applyDiscount(&s)
	fmt.Println(s.rate)

	// var value int = 2         // 声明一个int的变量value
	// var pointer *int = &value // 将变量value的地址赋值给pointer指针变量
	// fmt.Println(pointer)      //打印指针变量，返回一个地址
	// var pointer2 *int = pointer

	// fmt.Println(*pointer) //打印指针变量pointer处的值
	// *pointer = 3
	// fmt.Println(value)
	// fmt.Println(pointer2)
	// fmt.Println(*pointer2)
	fmt.Println("-------------------------------------------------------------------------")

	var value myStuct
	value.myField = 3
	var pointer *myStuct = &value
	fmt.Println((*pointer).myField)
	fmt.Println(pointer.myField)
	fmt.Println("-------------------------------------------------------------------------")
	pointer.myField = 100
	fmt.Println((*pointer).myField)
	fmt.Println(pointer.myField)
}
